<?php

use yii\db\Migration;

class m180525_074503_create_consume_pay_mode extends Migration
{
    public function safeUp()
    {
        $tableOptions = null;
        if ($this->db->driverName === 'mysql') {
            $tableOptions = 'CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=InnoDB';
        }
        $this->createTable('{{%consume_pay_mode}}', [
            'id' => $this->primaryKey(),
            'module_id' => $this->integer(11)->defaultValue(0)->comment('充值或消费id'),
            'code' => $this->string(50)->defaultValue(null)->comment('充值方式code'),
            'pay_method' => $this->string(20)->defaultValue(null)->comment('针对模块 （customer 会员 student 学员）'),
            'money' => $this->decimal(10,2)->defaultValue(0)->comment('金额'),
            'type' => $this->smallInteger(2)->defaultValue(1)->comment('类型（1 充值 2 消费）'),
        ],$tableOptions);
    }

    public function safeDown()
    {
        $this->dropTable('{{%consume_pay_mode}}');
    }

    /*
    // Use up()/down() to run migration code without a transaction.
    public function up()
    {

    }

    public function down()
    {
        echo "m180525_074503_create_consume_pay_mode cannot be reverted.\n";

        return false;
    }
    */
}
